package com.cxyd.modules.wcs.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cxyd.modules.log.service.SysLogWorkService;
import com.cxyd.modules.wcs.dao.PlcItemDao;
import com.cxyd.modules.wcs.entity.PlcItemEntity;
import com.cxyd.modules.wcs.service.PlcItemService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Slf4j
@Service
public class PlcItemServiceImpl implements PlcItemService {
    @Resource
    private PlcItemDao itemDao;

    @Override
    public boolean signalJudge(String contNo, String agvCode, String agvType) {

        QueryWrapper<PlcItemEntity> qw = new QueryWrapper<>();
        qw.lambda().eq(PlcItemEntity::getItemCode, agvType)
                .eq(PlcItemEntity::getItemGrp, "PLC_AGREE");
        PlcItemEntity item = itemDao.selectOne(qw);
        if (item == null) {
            return false;
        }
        //无论取还是放,只要PLC那边AGREE信号=1则返回成功
        if ("1".equals(item.getItemValue())) {
            return true;
        }
        return false;
    }
}
